<template>
  <div>
    <!-- <h2>Not Found</h2> -->
    <h2>Page Not Found!</h2>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import {
  requestUserMenusByRoleId,
  requestUserInfoById
} from '@/service/login/login'
import localCache from '@/utils/cache'
import router from '@/router'

export default defineComponent({
  setup() {
    // const userInfo = localCache.getCache('userInfo')
    // console.log(userInfo)
    const getUserMenus = async () => {
      const user = localCache.getCache('userInfo')
      console.log(user)
      const userInfoResult = await requestUserInfoById(user.id)
      const userInfo = userInfoResult.data
      const userMenusResult = await requestUserMenusByRoleId(userInfo.roleId)
      const userMenus = userMenusResult.data.menuList
      console.log(userMenus)
      localCache.setCache('userMenus', userMenus)
      for (const i of userMenus) {
        // console.log(i)
        // console.log(i.children)
        for (const j of i.children) {
          console.log(j.url)
          if (j.url == '/main/mrr/dashboard') {
            console.log('router to MRR')
            router.push(j.url)
          }

          router.push('/main')
        }
      }
    }
    getUserMenus()

    return {}
  }
})
</script>

<style scoped></style>
